using System.Collections.Generic;
using TrueSync;

namespace HEFramework
{
    [Invoke((long)eSceneType.Main)]
    public class Invoke_Scene_Main : AInvokeHandler<SceneInfo>
    {
        public override void Handle(SceneInfo _args)
        {
            Log.Debug("场景开始 - >" + _args.Scene.SceneType);

            Entity scene = _args.Scene;
            scene.AddChild<TimerComponent>();
            scene.AddChild<DataTableComponent>();
            scene.AddChild<UIComponent>();
            scene.AddChild<ResourcesComponent>();
            scene.AddChild<DownUI>();
        }
    }


    [Invoke((long)eSceneType.Game)]
    public class Invoke_Scene_Game : AInvokeHandler<SceneInfo>
    {
        public override void Handle(SceneInfo _args)
        {
            Log.Debug("场景开始 - >" + _args.Scene.SceneType);

            Entity scene = _args.Scene;
            scene.AddChild<TimerComponent>();
            scene.AddChild<UIComponent>();
            scene.AddChild<ResourcesComponent>();
            scene.AddChild<PrefabComponent>();
            scene.AddChild<AudioComponent, int>(0);
            scene.AddChild<DataTableComponent>();

            scene.AddChild<Camp, int, object>(0, new List<Camp.Group>()
            {
                new()
                {
                    ID = 0,
                    Singles = new()
                    {
                        new()
                        {
                            ID = 0,
                        },
                    }
                },
                new()
                {
                    ID = 1,
                    Singles = new()
                    {
                        new()
                        {
                            ID = 1,
                        },
                    }
                }
            });

            scene.AddChild<Reward>();
            scene.AddChild<Statistic>();
            scene.AddChild<Factory>();
            scene.AddChild<Team>();
            scene.AddChild<Trial>();
            scene.AddChild<Summon>();
            scene.AddChild<Player>();
            scene.AddChild<Round>();
            scene.AddChild<Map>();
            scene.AddChild<Building, int>(1000);
            scene.AddChild<Legacy>();
            scene.AddChild<LegacyLottery>();
            scene.AddChild<Element>();
            scene.AddChild<Theme, int>((int)_args.Message);

            scene.AddChild<GameCamera>();
            scene.AddChild<GameUI>();
            scene.AddChild<ReporterUI>();
            scene.AddChild<TeamUI>();
            scene.AddChild<SummonUI>();
            scene.AddChild<TrialUI>();
            scene.AddChild<LegacyLotteryUI>();
            scene.AddChild<LegacyInfoUI>();
            scene.AddChild<ElementUI>();
            scene.AddChild<HeroInfoUI>();
            scene.AddChild<HUD>();
            scene.AddChild<SceneTouch>();
#if DEBUG_SHOW
            scene.AddChild<StatisticUI>();
            scene.AddChild<DebugUI>();
            scene.AddChild<DebugDraw>();
#endif


            //生成房子
            int teamID;
            var camp = scene.GetChild<Camp>();
            teamID = camp.MyID;
            scene.GetChild<Factory>().AddBuilding(1000, teamID, new TSVector());

            //调整镜头
            var map = scene.GetChild<Map>();
            var camera = scene.GetChild<GameCamera>();
            var transform = map.GetChild<MapView>().GetChild<GameObjectComponent>().GameObject.transform;
            camera.SetTarget(transform);
        }
    }


    [Invoke((long)eSceneType.Test)]
    public class Invoke_Scene_Test : AInvokeHandler<SceneInfo>
    {
        public override void Handle(SceneInfo _args)
        {
            Log.Debug("场景开始 - >" + _args.Scene.SceneType);

            Entity scene = _args.Scene;
            scene.AddChild<TimerComponent>();
            scene.AddChild<UIComponent>();
            scene.AddChild<ResourcesComponent>();
            scene.AddChild<PrefabComponent>();
            scene.AddChild<AudioComponent, int>(0);
            scene.AddChild<DataTableComponent>();


            scene.AddChild<Camp, int, object>(0, new List<Camp.Group>()
            {
                new()
                {
                    ID = 0,
                    Singles = new()
                    {
                        new()
                        {
                            ID = 0,
                        },
                    }
                },
                new()
                {
                    ID = 1,
                    Singles = new()
                    {
                        new()
                        {
                            ID = 1,
                        },
                    }
                }
            });

            scene.AddChild<Reward>();
            scene.AddChild<Statistic>();
            scene.AddChild<Factory>();
            scene.AddChild<Team>();
            scene.AddChild<Trial>();
            scene.AddChild<Summon>();
            scene.AddChild<Player>();

            scene.AddChild<Map>();
            scene.AddChild<Legacy>();
            scene.AddChild<LegacyLottery>();
            scene.AddChild<Element>();
            scene.AddChild<Theme, int>((int)_args.Message);

            scene.AddChild<GameCamera>();
            scene.AddChild<GameUI>();
            scene.AddChild<ReporterUI>();
            scene.AddChild<TeamUI>();
            scene.AddChild<SummonUI>();
            scene.AddChild<TrialUI>();
            scene.AddChild<LegacyLotteryUI>();
            scene.AddChild<LegacyInfoUI>();
            scene.AddChild<ElementUI>();
            scene.AddChild<HeroInfoUI>();
            scene.AddChild<HUD>();
            scene.AddChild<SceneTouch>();
#if DEBUG_SHOW
            scene.AddChild<StatisticUI>();
            scene.AddChild<DebugUI>();
            scene.AddChild<DebugDraw>();
#endif

            //生成房子
            int teamID;
            var camp = scene.GetChild<Camp>();
            teamID = camp.MyID;
            scene.GetChild<Factory>().AddBuilding(1000, teamID, new TSVector());

            //调整镜头
            var map = scene.GetChild<Map>();
            var camera = scene.GetChild<GameCamera>();
            var transform = map.GetChild<MapView>().GetChild<GameObjectComponent>().GameObject.transform;
            camera.SetTarget(transform);
        }
    }
}